home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Pascal / Snippets / DimText Pascal 1.0 / main.p < prev   
Encoding:
Text File  |  1995-04-18  |  1.7 KB  |  94 lines  |  [TEXT/PJMM]

  1. {Dimming demo}
  2. {Converted to Pascal 1995 by IR}
  3.  
  4. program Dim;
  5.  
  6.     uses
  7.         Dim_text;
  8.  
  9. { dialog item numbers}
  10.     const
  11.         i_done = 1;
  12.         i_title = 2;
  13.         i_checkbox1 = 3;
  14.         i_checkbox2 = 4;
  15.         i_stat1 = 5;
  16.         i_edit1 = 6;
  17.         i_edit3 = 7;
  18.         i_stat2 = 8;
  19.         i_edit2 = 9;
  20.         i_refresh = 10;
  21.  
  22.  
  23.     procedure ToolBoxInit;
  24.     begin
  25. {$IFC UNDEFINED THINK_PASCAL}
  26.         InitGraf(@qd.thePort);
  27.         InitFonts;
  28.         FlushEvents(everyEvent, o);
  29.         InitWindows;
  30.         InitMenus;
  31.         TEInit;
  32.         InitDialogs(nil);
  33. {$ENDC}
  34.         InitCursor;
  35.     end; {ToolBoxInit}
  36.  
  37.  
  38. {main program}
  39.  
  40.     var
  41.         dp: DialogPtr;
  42.         checkbox1, checkbox2: ControlHandle;
  43.         iRect: Rect;
  44.         iType, hit: Integer;
  45.         val: Boolean;
  46.         apple_menu: MenuHandle;
  47.  
  48. begin
  49.     ToolBoxInit;
  50.     apple_menu := NewMenu(128, stringof(char($14)));
  51.     AppendMenu(apple_menu, 'Yo;(-');
  52.     AddResMenu(apple_menu, 'DRVR');
  53.     InsertMenu(apple_menu, 0);
  54.     DrawMenuBar;
  55.  
  56.     dp := GetNewDialog(128, nil, WindowPtr(-1));
  57.     SetPort(dp);
  58.     GetDItem(dp, i_checkbox1, iType, Handle(checkbox1), iRect);
  59.     GetDItem(dp, i_checkbox2, iType, Handle(checkbox2), iRect);
  60.     Init_dimmer(dp);
  61.  
  62.     ShowWindow(dp);
  63.     repeat
  64.  
  65.         ModalDialog(nil, hit);
  66.         case hit of
  67.             i_checkbox1: 
  68.                 begin
  69.                     val := not Boolean(GetCtlValue(checkbox1));
  70.                     SetCtlValue(checkbox1, Integer(val));
  71.                     Dim_text(dp, i_stat1, val);
  72.                     Dim_text(dp, i_edit1, val);
  73.                     Dim_text(dp, i_edit3, val);
  74.                 end;
  75.  
  76.             i_checkbox2: 
  77.                 begin
  78.                     val := not Boolean(GetCtlValue(checkbox2));
  79.                     SetCtlValue(checkbox2, Integer(val));
  80.                     Dim_text(dp, i_stat2, val);
  81.                     Dim_text(dp, i_edit2, val);
  82.                 end;
  83.  
  84.             i_refresh: 
  85.                 begin
  86.                     EraseRect(dp^.portRect);
  87.                     InvalRect(dp^.portRect);
  88.                 end;
  89.         end; {case}
  90.     until hit = i_done;
  91.  
  92.     Dispose_dimmer(dp);
  93.     DisposeDialog(dp);
  94. end.